package com.paas.form.core.element.base;

import com.gencode.util.CodeBuildNew;
import com.paas.common.util.StringUtil;
import com.paas.form.core.element.FieldElement;
import com.paas.form.core.element.constants.TreeConstant;
import com.paas.form.core.element.jsContent.ScriptContent;

import java.util.HashMap;
import java.util.Map;

public class Tree implements FieldElement {

    Map<String, Object> map = new HashMap<>();

    /*
    * config中应有配置项
    *treeTitle、treeRelation、treeLazyType、treePropsValue、treePropsChildren、treePropsLabel、treeDataSource
    *treeDictionary
    * */

    public Tree(Map<String, Object> configMap){
        map.putAll(configMap);
    }


    @Override
    public String makeVue() {
        String treeHtmlStr = CodeBuildNew.getCodeString(map, TreeConstant.VM_TREE_HTML);
        return treeHtmlStr;
    }

    @Override
    public ScriptContent makeJs() {
        ScriptContent scriptContent = new ScriptContent();
        scriptContent.setData(CodeBuildNew.getCodeString(map,TreeConstant.VM_TREE_JS_DATA));
        scriptContent.setMethods(CodeBuildNew.getCodeString(map,TreeConstant.VM_TREE_JS_METHODS));
        return scriptContent;
    }
}
